|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectserialio.Serial
public class Serial
Serielle Ein-/Ausgabe.
Ein Objekt der Klasse Serial kapselt eine serielle Schnittstelle und damit
einen seriellen Port. Festlegung der Übertragungs-Parameter kann nur bei
der Objekt-Erzeugung vorgenommen werden.
Wenn alles gutgegangen ist, ist das Serial-Objekt danach bereit.
Dies kann durch den Rückgabewert der Methode
open() festgestellt werden (true bei bereit).
Das Serial-Objekt gestattet im Zustand "bereit" das Lesen bzw.
Schreiben von einzelnen Bytes, Byte-Arrays oder Strings von der bzw. auf
die seriellen Schnittstelle.
Installation
Die Java-COMM-Extensions, also das Paket javax.comm, gehört nicht
zum JDK/JRE-Standard-Umfang und erfordert also die Installation
im JDK oder JRE als installed extensions.
Copyright 2006, Michael Zimmer
javax.comm.SerialPort| Field Summary | |
|---|---|
static int |
DATABITS_5
|
static int |
DATABITS_6
|
static int |
DATABITS_7
|
static int |
DATABITS_8
|
static int |
PARITY_EVEN
|
static int |
PARITY_NONE
|
static int |
PARITY_ODD
|
static int |
STOPBITS_1
|
static int |
STOPBITS_1_5
|
static int |
STOPBITS_2
|
| Constructor Summary | |
|---|---|
Serial(java.lang.String portName,
int baudrate,
int dataBits,
int stopBits,
int parity)
Konstruktor. |
|
| Method Summary | |
|---|---|
void |
close()
Schließt die serielle Schnittstelle. |
int |
dataAvailable()
Prüfen, ob Daten verfügbar sind. |
boolean |
isCTS()
Status des Modem-Meldeeingangs CTS (clear to send). |
boolean |
isDSR()
Status des Modem-Meldeeingangs DSR (data set ready). |
boolean |
open()
Öffnet die serielle Schnittstelle. |
int |
read()
Lesen eines Zeichens vom COM-Port. |
int |
read(byte[] b,
int len)
Lesen von Bytes vom COM-Port. |
java.lang.String |
readLine()
Lesen eines Strings vom COM-Port. |
void |
setDTR(boolean arg)
Setzen des Modem-Steuerausgangs DTR (data terminal ready). |
void |
setRTS(boolean arg)
Setzen des Modem-Steuerausgangs RTS (request to send). |
void |
write(byte[] b,
int len)
Schreiben von Bytes auf den COM-Port. |
void |
write(int b)
Schreiben eines Zeichens auf den COM-Port. |
void |
write(java.lang.String s)
Schreiben eines String auf den COM-Port. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DATABITS_5
public static final int DATABITS_6
public static final int DATABITS_7
public static final int DATABITS_8
public static final int STOPBITS_1
public static final int STOPBITS_2
public static final int STOPBITS_1_5
public static final int PARITY_NONE
public static final int PARITY_ODD
public static final int PARITY_EVEN
| Constructor Detail |
|---|
public Serial(java.lang.String portName,
int baudrate,
int dataBits,
int stopBits,
int parity)
throws java.lang.Exception
portName - Der Name des Ports, z.B. COM1, COM2baud - BaudratedataBits - Anzahl der Datenbitsparity - ParitätstopBits - Anzahl der Stopbits
java.lang.Exception| Method Detail |
|---|
public boolean open()
throws java.lang.Exception
java.lang.Exception
public void close()
throws java.io.IOException
java.io.IOException
public int dataAvailable()
throws java.io.IOException
java.io.IOException
public int read()
throws java.io.IOException
java.io.IOException
public int read(byte[] b,
int len)
throws java.io.IOException
b - Der Bufferlen - Max. Anzahl der zu lesenden Bytes
java.io.IOException
public java.lang.String readLine()
throws java.io.IOException
java.io.IOException
public void write(int b)
throws java.io.IOException
b - Das zu schreibende Byte (0..255)
java.io.IOException
public void write(byte[] b,
int len)
throws java.io.IOException
b - Der Bufferlen - Max. Anzahl der zu schreibenden Bytes
java.io.IOException
public void write(java.lang.String s)
throws java.io.IOException
s - Der String
java.io.IOExceptionpublic void setRTS(boolean arg)
arg - true, um RTS zu setzenpublic void setDTR(boolean arg)
arg - true, um DTR zu setzenpublic boolean isCTS()
public boolean isDSR()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||